﻿<!--
	========================================================================
	 awzBoxes Library
	
	 Homepage: http://www.awzhome.de/
	========================================================================
	
	This Source Code Form is subject to the terms of the Mozilla Public
	License, v. 2.0. If a copy of the MPL was not distributed with this
	file, You can obtain one at http://mozilla.org/MPL/2.0/.
   
	The Original Code is code of awzBoxes Library.

	The Initial Developer of the Original Code is Andreas Weizel.
	Portions created by the Initial Developer are
	Copyright (C) 2011-2012 Andreas Weizel. All Rights Reserved.
	
	Contributor(s): (none)
	
	========================================================================
-->

<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:box="clr-namespace:AWZhome.awzBoxes"
	xmlns:boxt="clr-namespace:AWZhome.awzBoxes.Tools">

	<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

	<!-- Style of BoxWindowContainer control -->
	<Style TargetType="box:BoxWindowContainer">
		<Setter Property="Background" Value="{x:Static SystemColors.ControlBrush}" />
	</Style>

	<!-- Style of BoxItem elements in window selector popup -->
	<Style x:Key="BoxItemListItemStyle" TargetType="ListBoxItem">
		<Setter Property="FocusVisualStyle" Value="{x:Null}" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="ListBoxItem">
					<Border
						Name="Border"
						Padding="2"
						SnapsToDevicePixels="true">
						<TextBlock Name="Text" Text="{Binding Title}" />
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsSelected" Value="true">
							<Setter TargetName="Border" Property="Background"
										Value="{x:Static SystemColors.HighlightBrush}"/>
							<Setter TargetName="Text" Property="Foreground"
										Value="{x:Static SystemColors.HighlightTextBrush}"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<!-- Style of auto-hide button images -->
	<Style x:Key="AutoHideButtonImageStyle" TargetType="{x:Type Image}">
		<Setter Property="Height" Value="16" />
		<Setter Property="Width" Value="16" />
		<Setter Property="Margin" Value="0,0,2,0" />
		<!--<Setter Property="Visibility" Value="Visible" />-->
		<Style.Triggers>
			<Trigger Property="Source" Value="{x:Null}">
				<Setter Property="Visibility" Value="Collapsed" />
			</Trigger>
		</Style.Triggers>
	</Style>

	<!-- RadioButton style for auto-hide buttons -->
	<Style x:Key="AutoHideButtonStyle" TargetType="{x:Type CheckBox}">
		<Setter Property="Focusable" Value="False" />
		<Setter Property="IsTabStop" Value="False" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type CheckBox}">
					<ControlTemplate.Resources>
						<Style TargetType="{x:Type Image}">
							<Setter Property="VerticalAlignment" Value="Center"/>
						</Style>
						<Style TargetType="{x:Type TextBlock}">
							<Setter Property="VerticalAlignment" Value="Center"/>
						</Style>
						<Style TargetType="{x:Type Label}">
							<Setter Property="Padding" Value="0"/>
							<Setter Property="VerticalAlignment" Value="Center"/>
						</Style>
					</ControlTemplate.Resources>
					<Border
							x:Name="PART_border" CornerRadius="2" Padding="3" Margin="2"
							Background="Transparent" BorderThickness="1"
							BorderBrush="{x:Static SystemColors.ControlDarkBrush}" SnapsToDevicePixels="True">

						<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
							<ContentPresenter x:Name="PART_content" />
						</StackPanel>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsChecked" Value="True">
							<Setter TargetName="PART_content" Property="TextBlock.FontWeight" Value="Bold"/>
							<Setter TargetName="PART_border" Property="Background">
								<Setter.Value>
									<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
										<GradientStop Color="{x:Static SystemColors.ControlLightColor}" Offset="0"/>
										<GradientStop Color="{x:Static SystemColors.ControlColor}" Offset="1"/>
									</LinearGradientBrush>
								</Setter.Value>
							</Setter>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<!-- ListBox style hiding borders and white background -->
	<Style x:Key="AutoHideListBoxStyle" TargetType="{x:Type ItemsControl}">
		<Setter Property="Background" Value="Transparent" />
		<Setter Property="BorderThickness" Value="0" />
	</Style>

	<!-- Template for horizontal auto-hide buttons -->
	<DataTemplate x:Key="AutoHideButtonHorizontalTemplate" DataType="box:BoxItem">
		<CheckBox
				Style="{Binding Source={StaticResource AutoHideButtonStyle}}"
				IsChecked="{Binding IsAutoHideOpen}"
				Command="box:BoxCommands.BoxAutoHideTrigger"
				CommandParameter="{Binding}">
			<CheckBox.Content>
				<StackPanel Orientation="Horizontal">
					<Image Source="{Binding Icon}" Style="{Binding Source={StaticResource AutoHideButtonImageStyle}}" />
					<TextBlock Text="{Binding Title}" />
				</StackPanel>
			</CheckBox.Content>
		</CheckBox>
	</DataTemplate>

	<!-- Template for vertical auto-hide buttons -->
	<DataTemplate x:Key="AutoHideButtonVerticalTemplate" DataType="box:BoxItem">
		<CheckBox
				Style="{Binding Source={StaticResource AutoHideButtonStyle}}"
				IsChecked="{Binding IsAutoHideOpen, Mode=TwoWay}"
				Command="box:BoxCommands.BoxAutoHideTrigger"
				CommandParameter="{Binding}">
			<CheckBox.LayoutTransform>
				<RotateTransform CenterX="0" CenterY="0" Angle="90" />
			</CheckBox.LayoutTransform>
			<CheckBox.Content>
				<StackPanel Orientation="Horizontal">
					<Image Source="{Binding Icon}" Style="{Binding Source={StaticResource AutoHideButtonImageStyle}}" />
					<TextBlock Text="{Binding Title}" />
				</StackPanel>
			</CheckBox.Content>
		</CheckBox>
	</DataTemplate>

	<!-- Template for AutoHiddenBoxes in horizontal orientation -->
	<DataTemplate x:Key="AutoHiddenBoxHorizontalTemplate" DataType="box:AutoHiddenBox">
		<ItemsControl
				ItemsSource="{Binding Items}"
				ItemTemplate="{Binding Source={StaticResource AutoHideButtonHorizontalTemplate}}"
				Style="{Binding Source={StaticResource AutoHideListBoxStyle}}">

			<ItemsControl.ItemsPanel>
				<ItemsPanelTemplate>
					<StackPanel Orientation="Horizontal" />
				</ItemsPanelTemplate>
			</ItemsControl.ItemsPanel>
		</ItemsControl>
	</DataTemplate>

	<!-- Template for AutoHiddenBoxes in vertical orientation -->
	<DataTemplate x:Key="AutoHiddenBoxVerticalTemplate" DataType="box:AutoHiddenBox">
		<ItemsControl
				ItemsSource="{Binding Items}"
				ItemTemplate="{Binding Source={StaticResource AutoHideButtonVerticalTemplate}}"
				Style="{Binding Source={StaticResource AutoHideListBoxStyle}}">

			<ItemsControl.ItemsPanel>
				<ItemsPanelTemplate>
					<StackPanel Orientation="Vertical"/>
				</ItemsPanelTemplate>
			</ItemsControl.ItemsPanel>
		</ItemsControl>
	</DataTemplate>

	<!-- Style for auto-hide title buttons -->
	<Style
		x:Key="AutoHidePopupHeaderButtonStyle" TargetType="{x:Type Button}"
		BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
		
		<Setter Property="VerticalAlignment" Value="Center" />
		<Setter Property="HorizontalAlignment" Value="Right" />
		<Setter Property="Width" Value="16" />
		<Setter Property="Height" Value="16" />
		<Setter Property="Padding" Value="0,0,0,0" />
		<Setter Property="Focusable" Value="False" />
		<Style.Triggers>
			<MultiDataTrigger>
				<MultiDataTrigger.Conditions>
					<Condition Binding="{Binding IsHighlighted}" Value="True" />
					<Condition Binding="{Binding IsLocallyActive}" Value="False" />
				</MultiDataTrigger.Conditions>
				<Setter Property="Foreground" Value="{x:Static SystemColors.HighlightTextBrush}" />
			</MultiDataTrigger>
		</Style.Triggers>
	</Style>

	<!-- Style of the title bar for auto-hide popup -->
	<Style TargetType="{x:Type Label}" x:Key="AutoHidePopupTitleStyle">
		<Setter Property="Foreground" Value="{x:Static SystemColors.ActiveCaptionTextBrush}" />
		<Setter Property="HorizontalContentAlignment" Value="Stretch" />
		<Setter Property="VerticalContentAlignment" Value="Stretch" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Label}">
					<Border Background="{x:Static SystemColors.ActiveCaptionBrush}">
						<Grid Margin="2,2,2,2">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="*" />
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition Width="Auto" />
							</Grid.ColumnDefinitions>
							<ContentPresenter
									Grid.Column="0"
									HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
									VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
									RecognizesAccessKey="True" />
							<Button
									Grid.Column="1" FontFamily="Marlett" Margin="7,0,0,0" Padding="0,0,0,0"
									Foreground="{x:Static SystemColors.ActiveCaptionTextBrush}"
									Style="{StaticResource AutoHidePopupHeaderButtonStyle}"
									Command="box:BoxCommands.AutoHideBoxItemRedock"
									CommandParameter="{Binding}">v</Button>
							<Button
									Grid.Column="2" FontFamily="Marlett" Margin="0,0,0,0" Padding="0,0,0,0"
									Foreground="{x:Static SystemColors.ActiveCaptionTextBrush}"
									Style="{StaticResource AutoHidePopupHeaderButtonStyle}"
									Visibility="{Binding Path=IsClosable, Converter={StaticResource BooleanToVisibilityConverter}}"
									Command="box:BoxCommands.AutoHideBoxItemClose"
									CommandParameter="{Binding}">r</Button>
						</Grid>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<!-- Style of auto-hide window border -->
	<Style x:Key="AutoHidePopupBorderStyle" TargetType="{x:Type Border}">
		<Setter Property="Background" Value="{x:Static SystemColors.ControlBrush}" />
		<Setter Property="BorderBrush" Value="{x:Static SystemColors.ControlDarkBrush}" />
		<Setter Property="BorderThickness" Value="1" />
	</Style>

	<!-- Styles of resize thumbs -->
	<Style x:Key="AutoHidePopupThumbStyle" TargetType="{x:Type Thumb}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Thumb}">
					<StackPanel Background="{TemplateBinding Background}" />
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="AutoHidePopupHorizontalThumbStyle" TargetType="{x:Type Thumb}" BasedOn="{StaticResource AutoHidePopupThumbStyle}">
		<Setter Property="Cursor" Value="SizeNS" />
		<Setter Property="Height" Value="3" />
	</Style>

	<Style x:Key="AutoHidePopupVerticalThumbStyle" TargetType="{x:Type Thumb}" BasedOn="{StaticResource AutoHidePopupThumbStyle}">
		<Setter Property="Cursor" Value="SizeWE" />
		<Setter Property="Width" Value="3" />
	</Style>
	
</ResourceDictionary>